#ifndef APPROXY4ESP_H
#define APPROXY4ESP_H

#include "driver/gpio.h"
#include "driver/ledc.h"
#include "esp_err.h"
#include "protocol.h"


esp_err_t start_Approxy4Esp(char *pUserName,int nUserNameLen,char *pPassword,int nPasswordLen,int nAutoLogin);

/************************************************************************/
/* 指令解析工作线程														*/
/************************************************************************/
void *HandleSacSCMWorker(void *arg) ;

// 解析从服务器发送回来的sac数据包
int HandleSacPackage(int * nSac,char * szRtJson, int * nRtJsonLen,int sockfd);


Approxy4cST_t *FindApproxy4cSTByChannelID(int channelID);

int SendSacSCMPackageToBeat(char *szRtJson,int *nRtJson,Approxy4cST_t *approxy4cST, char *_szSCM,char *_szSCMDA);

int SendSacSCMPackageToHost(char *szRtJson,int *nRtJson,Approxy4cST_t *approxy4cST,char *_szSCM,char *_szSCMDA,char *szHost,int nHostLen,int nPort);

/** 获取用户ID **/
int GetUidSTR(char *szUidSTR,int *pLen);
/** 获取用户openID **/
int GetLoginNameSTR(char *szSTR,int *pLen);
/** 获取用户openID **/
int GetSidSTR(char *szSidSTR,int *pLen);
int GetAccessTokenSTR(char *szAccessTokenSTR,int *pLen);

int GetMyWebCtxPathSTR(char *szCtxPathSTR,int *pLen);

int GetNewAccessTokenByOldToken(char *szAccessTokenSTR,int *pLen,char *szOldToken);

int GetClusterServer(Approxy4cST_t *approxy4cST);
#endif // APPROXY4ESP_H
    